package com.registerserver.dao;

import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class ConnectionFactory {

	public static final Connection createConnection() {
		Properties props = new Properties();
		Connection con = null;
		try {
		FileInputStream fi = new FileInputStream("resources/jdbc.properties");
		props.load(fi);
		Class.forName(props.getProperty("jdbc.class"));
		con = DriverManager.getConnection(props.getProperty("jdbc.url"),
				props.getProperty("jdbc.username"),
				props.getProperty("jdbc.password"));
		if (con != null)
			System.out.println("Connected");
		else
			System.out.println("Cannot connect");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return con;
	}
}
